/************************************************************************
** The main class for representing                                       
** an Actor, a Router, a Pool, or a Token.                              
** This class contain all information about what should be used in IDE  
*************************************************************************/

#ifndef ELEMENT_H
#define ELEMENT_H

#include <QtCore/QObject>
class QDomElement;
class QSvgRenderer;
class GElement;

/************************************************************************
**  Why? These global variables can't be placed in implementation file.
**       Link error.
**       But without const, they should be placed in implementation file.
**       If no, also Link error.
**       Does this speciality depend on compilers?
/************************************************************************/

//k denote keyword
const QString kActor("actor");
const QString kRouter("router");
const QString kPool("pool");
const QString kComposite("composite");

class DElement : public QObject
{
	Q_OBJECT

public:
	DElement(QObject *parent = 0);
	virtual ~DElement();

	//parse the element's description file
	virtual bool parseContent(const QString &xmlfile );
	virtual const QString kind() const =0;
	virtual QString className() const { return mClassName; }

	//Visitpr Pattern: Object/Element
	GElement* createGraphics();
	int count() { return mCount; } 
    
	QString displayName() const { return mDisplayName; }
	QString toolTip() const { return mToolTip; }
	QString statusTip() const { return mStatusTip; }
	QString whatsThis() const { return mWhatsThis; }
	QString funtion() const { return mFunction; }
	
	QSvgRenderer* renderer() const { return mRenderer; }

	QStringList* semantics() const { return mOntologies; }
	QStringList* patterns() const { return mPatterns; }
	QStringList* examples() const { return mExamples; }

protected:
	//Template Pattern
	//real create member function
	virtual GElement* doCreateGraphics() =0;
	virtual void parseDetail(const QDomElement& e) =0;
	virtual QString dir() const =0;

private:
	virtual QSvgRenderer* setRenderer(const QString &fileName);
	
	int mCount; //provide for create object name	
	QSvgRenderer* mRenderer; //All Graphics share this QSvgRenderer

	QString mDisplayName;
	QString mToolTip; 
	QString mStatusTip; 
	QString mWhatsThis;
	QString mClassName;
	QString mFunction;
	
	QStringList* mOntologies; //some relational ontologies
	QStringList* mPatterns;
	QStringList* mExamples;
};

#endif // ELEMENT_H
